using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Employee : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Cookies["userinfo"] != null)
        {
            Session["username"] = Request.Cookies["userinfo"].Values["username"].ToString();
        }

        if (Session["username"] != null)
        {
            lnkManager.Visible = true;
            lblSeperator.Visible = true;
            if (Roles.IsUserInRole(Session["username"].ToString(), "admin"))
            {
                lnkManager.Text = "Admin";
                lnkManager.PostBackUrl = "../Admin/Admin.aspx";
            }
            if (Roles.IsUserInRole(Session["username"].ToString(), "employee"))
            {
                lnkManager.Text = "Employee";
                lnkManager.PostBackUrl = "../Employee/DeliveryManager.aspx";
            }
        }
        else
        {
            lnkManager.Visible = false;
            lblSeperator.Visible = false;
        }
    }
    protected void LoginStatus1_LoggedOut(object sender, EventArgs e)
    {
        if (Request.Cookies["userinfo"] != null)
        {
            HttpCookie myCookie = new HttpCookie("userinfo");
            myCookie.Expires = DateTime.Now.AddDays(-1d);
            Response.Cookies.Add(myCookie);
        }
        Session["username"] = null;
        lnkManager.Visible = false;
        lblSeperator.Visible = false;
    }
}
